﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using Micrhard.FMCG.Server.Models;
using Micrhard.FMCG.Server.Msg;

namespace Micrhard.FMCG.Server.Validator
{
    public class NoticeModelValidator : AbstractValidator<NoticeModel>
    {
        public NoticeModelValidator()
        {
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Title).NotEmpty().WithMessage(NoticeMsg.NeedTitle).When(r => r.NoticeID == Guid.Empty);
                RuleFor(u => u.Title).Length(1, 50).WithMessage(NoticeMsg.TitleMaxLength).When(r => r.NoticeID == Guid.Empty);

                RuleFor(u => u.Message).NotEmpty().WithMessage(NoticeMsg.NeedMessage).When(r => r.NoticeID == Guid.Empty);
                RuleFor(u => u.Message).Length(1, 500).WithMessage(NoticeMsg.MessageMaxLength).When(r => r.NoticeID == Guid.Empty);
            });
        }
    }
}
